package com.znufe.exam.controller.admin;

import java.util.List;

import com.znufe.exam.base.BaseApiController;
import com.znufe.exam.viewmodel.admin.attendcourserecord.AttendCourseRecordCreateVM;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.znufe.exam.domain.AttendCourseRecord;
import com.znufe.exam.service.AttendCourseRecordService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import com.znufe.exam.base.RestResponse;
import com.znufe.exam.base.SystemCode;

/**   
 * 
 * @Description:  上课记录信息接口层
 * @Author:       lin keqing   
 * @CreateDate:   AttendCourseRecord
 * @Version:      V1.0
 *    
 */
@Api(description = "上课记录信息",value="上课记录信息" )
@RestController
@RequestMapping("/api/attendCourseRecord")
public class AttendCourseRecordController extends BaseApiController {

	Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	public AttendCourseRecordService attendCourseRecordService;


	@RequestMapping(value="/edit", method = RequestMethod.POST)
	@ApiOperation(value = "新增上课记录（新增）",
			notes = "新增上课记录[attend_course_record]，作者：lin keqing")
	public RestResponse<AttendCourseRecord> edit(@RequestBody AttendCourseRecordCreateVM model) {
		AttendCourseRecord attendCourseRecord = modelMapper.map(model, AttendCourseRecord.class);
		attendCourseRecord.setUserId(getCurrentUser().getId());

		logger.info("插入信息", attendCourseRecord);
		attendCourseRecordService.insertByFilter(attendCourseRecord);
		return RestResponse.ok(attendCourseRecord);
	}


	/**
	 * @explain 查询上课记录信息对象  <swagger GET请求>
	 * @param   id
	 * @return  attendCourseRecord
	 * @author  lin keqing
	 * @time    AttendCourseRecord
	 */
	/*
	@GetMapping("/getAttendCourseRecordById/{id}")
	@ApiOperation(value = "获取上课记录信息信息", notes = "获取上课记录信息信息[attendCourseRecord]，作者：lin keqing")
	@ApiImplicitParam(paramType="path", name = "id", value = "上课记录信息id", required = true, dataType = "Integer")
	public RestResponse<AttendCourseRecord> getAttendCourseRecordById(@PathVariable("id")Integer id){

		try {
			AttendCourseRecord attendCourseRecord=attendCourseRecordService.selectByPrimaryKey(id);
			if (attendCourseRecord!=null) {
				return RestResponse.ok(attendCourseRecord);
			} else {
				logger.error("查询上课记录信息执行失败："+attendCourseRecord.toString());
				return RestResponse.fail(SystemCode.NoDataExist.getCode(),SystemCode.NoDataExist.getMessage());
			}
		} catch (Exception e) {
			logger.error("查询上课记录信息执行异常："+e.getMessage());
			return RestResponse.fail(SystemCode.InnerError.getCode(),SystemCode.InnerError.getMessage());
		}
	}
	*/
	/**
	 * @explain 添加上课记录信息对象
	 * @param   attendCourseRecord
	 * @return  int
	 * @author  lin keqing
	 * @time    AttendCourseRecord
	 */
	/*
	@PostMapping("/insertSelective")
	@ApiOperation(value = "添加上课记录信息", notes = "添加上课记录信息[attendCourseRecord],作者：lin keqing")
	public RestResponse<Integer> insertSelective(@RequestBody AttendCourseRecord attendCourseRecord){
		try {
			int rg=attendCourseRecordService.insertSelective(attendCourseRecord);
			if (rg>0) {
				return RestResponse.ok(rg);
			} else {
				logger.error("添加上课记录信息执行失败："+attendCourseRecord.toString());
				return RestResponse.fail(SystemCode.InsertDataFail.getCode(),SystemCode.InsertDataFail.getMessage());
			}
		} catch (Exception e) {
			logger.error("添加上课记录信息执行异常："+e.getMessage());
			return RestResponse.fail(SystemCode.InnerError.getCode(),SystemCode.InnerError.getMessage());
		}
	}
	*/
	/**
	 * @explain 删除上课记录信息对象
	 * @param   id
	 * @return  int
	 * @author  lin keqing
	 * @time    AttendCourseRecord
	 */
	/*
	@PostMapping("/deleteByPrimaryKey")
	@ApiOperation(value = "删除上课记录信息", notes = "删除上课记录信息,作者：lin keqing")
	@ApiImplicitParam(paramType="query", name = "id", value = "上课记录信息id", required = true, dataType = "Integer")
	public RestResponse<Integer> deleteByPrimaryKey(Integer id){
		try {
			int reg=attendCourseRecordService.deleteByPrimaryKey(id);
			if (reg>0) {
				return RestResponse.ok(reg);
			} else {
				logger.error("删除上课记录信息失败ID："+id);
				return RestResponse.fail(SystemCode.DeleteDataFail.getCode(),SystemCode.DeleteDataFail.getMessage());
			}
		} catch (Exception e) {
			logger.error("删除上课记录信息执行异常："+e.getMessage());
			return RestResponse.fail(SystemCode.InnerError.getCode(),SystemCode.InnerError.getMessage());
		}
	}
	*/
	/**
	 * @explain 修改上课记录信息对象
	 * @param   attendCourseRecord
	 * @return  attendCourseRecord
	 * @author  lin keqing
	 * @time    AttendCourseRecord
	 */
	/*
	@ApiOperation(value = "修改上课记录信息", notes = "修改上课记录信息[attendCourseRecord],作者：lin keqing")
	@PostMapping("/updateByPrimaryKeySelective")
	public RestResponse<Integer> updateByPrimaryKeySelective(AttendCourseRecord attendCourseRecord){
		try {
			int reg = attendCourseRecordService.updateByPrimaryKeySelective(attendCourseRecord);
			if (reg>0) {
				return RestResponse.ok(reg);
			} else {
				logger.error("修改上课记录信息失败ID："+attendCourseRecord.toString());
				return RestResponse.fail(SystemCode.UpdateDataFail.getCode(),SystemCode.UpdateDataFail.getMessage());
			}
		} catch (Exception e) {
			logger.error("修改上课记录信息执行异常："+e.getMessage());
			return RestResponse.fail(SystemCode.InnerError.getCode(),SystemCode.InnerError.getMessage());
		}
	}
	*/
	/**
	 * @explain 获取匹配上课记录信息
	 * @param   attendCourseRecord
	 * @return  List<AttendCourseRecord>
	 * @author  lin keqing
	 * @time    AttendCourseRecord
	 */
	/*
	@ApiOperation(value = "条件查询上课记录信息", notes = "条件查询[attendCourseRecord],作者：lin keqing")
	@PostMapping("/queryAttendCourseRecordList")
	public RestResponse<List<AttendCourseRecord>> queryAttendCourseRecordList(AttendCourseRecord attendCourseRecord){
		try {
			List<AttendCourseRecord> list = attendCourseRecordService.queryAttendCourseRecordList(attendCourseRecord);
			return RestResponse.ok(list);
		} catch (Exception e) {
			logger.error("获取上课记录信息执行异常："+e.getMessage());
			return RestResponse.fail(SystemCode.InnerError.getCode(),SystemCode.InnerError.getMessage());
		}
	}
	*/
}